<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cherry 8x16 keyboard example</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51 General Code Examples
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__cherry8x16__example.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Defines</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">Cherry 8x16 keyboard example</div>  </div>
<div class="ingroups"><a class="el" href="group__nrf__examples__nrf6310.html">nRF6310 example projects</a></div></div>
<div class="contents">

<p>Cherry 8x16 keyboard example.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga4e7b3978e53f497b396f1d3d9ecb794b"></a><!-- doxytag: member="cherry8x16_example::USE_UART" ref="ga4e7b3978e53f497b396f1d3d9ecb794b" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><b>USE_UART</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#gafb80f61fa944be28d9895a47602e8957">SIMPLE_UART_TXD_PIN_NUMBER</a>&#160;&#160;&#160;(24U)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#ga93d696b159f34e012cf60f3c2e2050be">SIMPLE_UART_RXD_PIN_NUMBER</a>&#160;&#160;&#160;(25U)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga3375613e875ab025e3ff7441cea933cf"></a><!-- doxytag: member="cherry8x16_example::KEYPAD_NUM_OF_COLUMNS" ref="ga3375613e875ab025e3ff7441cea933cf" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#ga3375613e875ab025e3ff7441cea933cf">KEYPAD_NUM_OF_COLUMNS</a>&#160;&#160;&#160;16</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of columns in the keyboard matrix. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga3dd1faa92e9de0dc3858af5f114d1c38"></a><!-- doxytag: member="cherry8x16_example::KEYPAD_NUM_OF_ROWS" ref="ga3dd1faa92e9de0dc3858af5f114d1c38" args="" -->
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#ga3dd1faa92e9de0dc3858af5f114d1c38">KEYPAD_NUM_OF_ROWS</a>&#160;&#160;&#160;8</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of rows in the keyboard matrix. <br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#gab94a7d38d92cefba725521d954ede75a">uart_puthidstring</a> (const char *str)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#ga840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr><td colspan="2"><h2><a name="var-members"></a>
Variables</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const uint8_t volatile <br class="typebreak"/>
*const&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#ga7b0771426bcb19acdebee8b36aed8824">matrix_row_port</a> = ((uint8_t*)(&amp;NRF_GPIO-&gt;IN)) + 2</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static uint16_t *const&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#ga2d1e718ed363e61cd45e390db88f79b8">matrix_column_port</a> = ((uint16_t*)(&amp;NRF_GPIO-&gt;OUT))</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cherry8x16__example.html#ga144e0104b848cd4ac9000417a855d530">usb_hid2_ascii_look_up</a> [KEYPAD_NUM_OF_COLUMNS *KEYPAD_NUM_OF_ROWS]</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Cherry 8x16 keyboard example. </p>
<p>This example will detect the characters by scanning the matrix for any state change (key(s) press or release). If any changes from the previous state is identified, then the received key codes are converted from hid to ascii which are transmitted over uart and can be listened by any COM listener like example:PUTTY (this is default behavior). However commenting out USE_UART can be done to to output modifier key presses to LEDs through GPIOs.</p>
<p>This example is meant to be used with the nRF6423 board. Connect nRF6310 P1 to LEDs. Connections between the two boards: nRF6423 - nRF6310</p>
<p>(column lower) P3 - P0 (column higher) P4 - P1 (rows) P2 - P2</p>
<p>Can also be used with other keyboards, in which case row and column mapping have to be changed in this example </p>
<hr/><h2>Define Documentation</h2>
<a class="anchor" id="gafb80f61fa944be28d9895a47602e8957"></a><!-- doxytag: member="main.c::SIMPLE_UART_TXD_PIN_NUMBER" ref="gafb80f61fa944be28d9895a47602e8957" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SIMPLE_UART_TXD_PIN_NUMBER&#160;&#160;&#160;(24U)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Pin number to use as UART TXD, LEDs for modifier key presses and UART cannot be used at the same time as both use SIMPLE_UART_TXD_PIN_NUMBER, so comment out UART code if using LEDs for modifier keys and vice-versa </p>

<p>Definition at line <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html#l00050">50</a> of file <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga93d696b159f34e012cf60f3c2e2050be"></a><!-- doxytag: member="main.c::SIMPLE_UART_RXD_PIN_NUMBER" ref="ga93d696b159f34e012cf60f3c2e2050be" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SIMPLE_UART_RXD_PIN_NUMBER&#160;&#160;&#160;(25U)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Pin number to use as UART RXD, LEDs for modifier key presses and UART cannot be used at the same time as both use SIMPLE_UART_RXD_PIN_NUMBER, so comment out UART code if using LEDs for modifier keys and vice-versa </p>

<p>Definition at line <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html#l00055">55</a> of file <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gab94a7d38d92cefba725521d954ede75a"></a><!-- doxytag: member="main.c::uart_puthidstring" ref="gab94a7d38d92cefba725521d954ede75a" args="(const char *str)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static void uart_puthidstring </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>str</em></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sends a series of characters (string) to UART. Execution is blocked until UART peripheral reports character to have been send. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">str</td><td>Null terminated array of characters to send. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html#l00097">97</a> of file <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga840291bc02cba5474a4cb46a9b9566fe"></a><!-- doxytag: member="main.c::main" ref="ga840291bc02cba5474a4cb46a9b9566fe" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p><a class="el" href="group__gpio__example.html#ga840291bc02cba5474a4cb46a9b9566fe">main()</a> function </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0. int return type required by ANSI/ISO standard. </dd></dl>

<p>Definition at line <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html#l00113">113</a> of file <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<hr/><h2>Variable Documentation</h2>
<a class="anchor" id="ga7b0771426bcb19acdebee8b36aed8824"></a><!-- doxytag: member="main.c::matrix_row_port" ref="ga7b0771426bcb19acdebee8b36aed8824" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static const uint8_t volatile *const <a class="el" href="group__cherry8x16__example.html#ga7b0771426bcb19acdebee8b36aed8824">matrix_row_port</a> = ((uint8_t*)(&amp;NRF_GPIO-&gt;IN)) + 2<code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Pointer to GPIO memory are to use as a row port. No pointer alignment required for pointing to 8-bit values in this memory region. </p>

<p>Definition at line <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html#l00060">60</a> of file <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga2d1e718ed363e61cd45e390db88f79b8"></a><!-- doxytag: member="main.c::matrix_column_port" ref="ga2d1e718ed363e61cd45e390db88f79b8" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static uint16_t *const <a class="el" href="group__cherry8x16__example.html#ga2d1e718ed363e61cd45e390db88f79b8">matrix_column_port</a> = ((uint16_t*)(&amp;NRF_GPIO-&gt;OUT))<code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Pointer to GPIO memory are to use as a column port. Half-word alignment is required for pointing to 16-bit values in this memory region. </p>

<p>Definition at line <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html#l00065">65</a> of file <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga144e0104b848cd4ac9000417a855d530"></a><!-- doxytag: member="main.c::usb_hid2_ascii_look_up" ref="ga144e0104b848cd4ac9000417a855d530" args="[KEYPAD_NUM_OF_COLUMNS *KEYPAD_NUM_OF_ROWS]" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static const uint8_t <a class="el" href="group__cherry8x16__example.html#ga144e0104b848cd4ac9000417a855d530">usb_hid2_ascii_look_up</a><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Initial value:</b><div class="fragment"><pre class="fragment">
{
  0x00, 0x00, 0x00, 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
  0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
  0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30,
  0x0D, 0x1B, 0x08, 0x09, 0x20, 0x2D, 0x3D, 0x5B, 0x5D, 0x00,
  0x00, 0x3B, 0x27, 0x00, 0x2C, 0x2E, 0x2F, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
</pre></div><p>Table containing the mapping between the USB HID codes and ASCII values for most of the keys. </p>

<p>Definition at line <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html#l00075">75</a> of file <a class="el" href="nrf6310_2ext__sensors_2cherry8x16__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
